package com.msb.apiDriver.controller;

import com.msb.apiDriver.service.VerificationCodeService;
import com.msb.internalcommon.dto.ResponseResult;
import com.msb.internalcommon.request.VerificationCodeDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: jiudianliu
 * @Date: 2023/7/4 - 07 - 04 - 13:46
 * @Description: com.msb.apiDriver.controller
 * @version: 1.0
 */
@RestController
@Slf4j
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService ;

    @RequestMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String driverPhone = verificationCodeDTO.getDriverPhone();
        log.info("司机手机号：" + driverPhone);
        return verificationCodeService.checkAndsendVerificationCode(driverPhone);
    }

    /**
     * 校验验证码
     * @return
     */

    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String driverPhone = verificationCodeDTO.getDriverPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();
        System.out.println("手机号" + driverPhone + "验证码" + verificationCode);
        return verificationCodeService.checkCode(driverPhone,verificationCode) ;
    }
}
